﻿@using Microsoft.AspNetCore.Authorization
@using AuthorizationLab

@model IEnumerable<Document>
@inject IAuthorizationService AuthorizationService

<h1>Document Library</h1>
@{ 
    var requirement = new EditRequirement();
    foreach (var document in Model)
    {
        if (User.Identity.IsAuthenticated)
        {
            var authorizationResult = await AuthorizationService.AuthorizeAsync(User, document, requirement);

            if (authorizationResult.Succeeded)
            {
                <p>@Html.ActionLink("Document #" + document.Id, "Edit", new { id = document.Id })</p>
            }
        }
    }
}

